CREATE OR REPLACE PROCEDURE month_end_proc IS
	CURSOR c_account IS
		SELECT *
		FROM account;
BEGIN
	FOR r_account in c_account LOOP
		IF (r_account.account_type_code = 'RE') THEN
			INSERT INTO new_transactions
			VALUES (wkis_seq.NEXTVAL,sysdate,'Month end zeroing for revenue',r_account.account_no,'D',r_account.account_balance);
			
			INSERT INTO new_transactions
			VALUES (wkis_seq.CURRVAL,sysdate,'Month end zeroing for revenue',5555,'C',r_account.account_balance);	
		END IF;
		
		IF (r_account.account_type_code = 'EX') THEN
			INSERT INTO new_transactions
			VALUES (wkis_seq.NEXTVAL,sysdate,'Month end zeroing for expense',r_account.account_no,'C',r_account.account_balance);
			
			INSERT INTO new_transactions
			VALUES (wkis_seq.CURRVAL,sysdate,'Month end zeroing for expense',5555,'D',r_account.account_balance);
			
		END IF;
	END LOOP;
END;
/